package com.lx.patterns.memento.white;

/**
 * @ClassName GameRole
 * @Description: 游戏角色-发起人角色
 * @Author: 落雪
 * @CreateDate: 2025/2/15 15:19
 * @UpdateUser: 落雪
 * @UpdateDate: 2025/2/15 15:19
 * @UpdateRemark:
 * @Version: 1.0
 */
public class GameRole {

    private int vit; //生命力
    private int atk; //攻击力
    private int def; //防御力

    //初始状态
    public void initState(){
        this.vit = 100;
        this.atk = 100;
        this.def = 100;
    }
    //战斗
    public void fight(){
        this.vit = 0;
        this.atk = 0;
        this.def = 0;
    }
    //生成备忘录
    public RoleStateMemento saveState(){
        return new RoleStateMemento(vit,atk,def);
    }
    //恢复状态
    public void recoverState(RoleStateMemento memento){
        this.vit = memento.getVit();
        this.atk = memento.getAtk();
        this.def = memento.getDef();
    }

    public void showState(){
        System.out.println("角色生命力："+vit+"，攻击力："+atk+"，防御力："+def);
    }

}
